<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
	<xsl:param name="DOTNET2"/>

<xsl:output method="html" indent="yes"/>

	<xsl:template match="Class"><![CDATA[<?xml version="1.0" encoding="utf-8" ?>]]>
		<xsl:variable name="Name" select="Name"/>
<hibernate-mapping  xmlns="urn:nhibernate-mapping-2.2">
	
	<class lazy="true">
		<xsl:attribute name="table">[<xsl:value-of select="DBName"/>]</xsl:attribute>
		<xsl:attribute name="name"><xsl:value-of select="//HeaderInfo/ProjectName"/>.Core.Domain.DataAccess.<xsl:value-of select="Name"/>, <xsl:value-of select="//HeaderInfo/ProjectName"/>.Core</xsl:attribute>
		<id name="ObjectId" access="property">
			<xsl:attribute name="column"><xsl:value-of select="Name"/>ID</xsl:attribute>
			<generator class="guid"/>
		</id>
		<timestamp name="Modified" access="property" column="Modified" />
		
		    <xsl:for-each select="ClassAttribs/ClassAttributes[CType='single']">
		    
		    <xsl:if test="KnownClass='true'">
		<many-to-one access="property">
		<xsl:attribute name="name"><xsl:value-of select="PropertyName"/></xsl:attribute>
		<xsl:attribute name="column">[<xsl:value-of select="DBName"/>]</xsl:attribute>
		<xsl:attribute name="class"><xsl:value-of select="//HeaderInfo/ProjectName"/>.Core.Domain.DataAccess.<xsl:value-of select="Type"/>, <xsl:value-of select="//HeaderInfo/ProjectName"/>.Core</xsl:attribute>
		</many-to-one>
		    </xsl:if>
		    
		    
		     <xsl:if test="KnownClass!='true'">
		<property access="property">
		<xsl:attribute name="name"><xsl:value-of select="PropertyName"/></xsl:attribute>
		<xsl:attribute name="column">[<xsl:value-of select="DBName"/>]</xsl:attribute>
		</property>
		    </xsl:if>

		    
		    </xsl:for-each>
		    
		    
		<xsl:for-each select="ClassAttribs/ClassAttributes[CType='array']">
		<set access="property" lazy="true">
			<xsl:attribute name="name"><xsl:value-of select="PropertyName"/></xsl:attribute>
			<xsl:attribute name="table"><xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/></xsl:attribute>
			<key><xsl:attribute name="column"><xsl:if test="ColumnKey=''"><xsl:value-of select="Type"/><xsl:if test="$Name=Type">Item</xsl:if>ID</xsl:if><xsl:if test="ColumnKey!=''"><xsl:value-of select="ColumnKey"/></xsl:if></xsl:attribute></key>
			<many-to-many>
				<xsl:attribute name="column"><xsl:if test="ColumnRef=''"><xsl:value-of select="$Name"/>ID</xsl:if><xsl:if test="ColumnRef!=''"><xsl:value-of select="ColumnRef"/></xsl:if></xsl:attribute>
				<xsl:attribute name="class"><xsl:value-of select="//HeaderInfo/ProjectName"/>.Core.Domain.DataAccess.<xsl:value-of select="Type"/>, <xsl:value-of select="//HeaderInfo/ProjectName"/>.Core</xsl:attribute>
			</many-to-many>
		</set>

		</xsl:for-each>
	</class>

</hibernate-mapping>


	</xsl:template>
	
</xsl:stylesheet>